const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
const options = {};
module.exports = {
  mode: "development",
  entry: {
    app: "./src/index.js",
    // print: './src/print.js'
    //   vue:'./src/vue.js'
  },
  devtool: "inline-source-map",
  devServer: {
    contentBase: "./dist",
    hot: true,
  },
  plugins: [
    new CleanWebpackPlugin({ cleanStaleWebpackAssets: false }),
    new HtmlWebpackPlugin({
      inject: false,
      template: require("html-webpack-template"),
      title: "首页3",
      bodyHtmlSnippet: "<p>我是插入到body中的p标签</p>"
    }),
    //  new HtmlWebpackPlugin({template: './src/index.html',title: "首页2"}),
    new WebpackManifestPlugin(options),
  ],
  output: {
    filename: "[name].js",
    path: __dirname + "/dist",
  },
  module: {
    rules: [
      {
        test: /\.m?js$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-env", "@babel/preset-react"],
            plugins: ["@babel/plugin-proposal-class-properties"],
          },
        },
      },
    ],
  },
};
